<html>
<head>
    <title>股东等级列表</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/static/layui//css/layui.css">
    <script src="/static/layui/layui.all.js"></script>
    <script src="/static/js/jquery.min.js"></script>
    <script src="/static/js/dealParam.js"></script>
    <script src="/static/js/CodeConst.js"></script>
    <script src="/static/js/common.js"></script>

</head>

<style>
    .laytable-cell-1-0 {
        width: 48px;
    }

    .laytable-cell-1-ll {
        width: 80px;
    }

    .laytable-cell-1-lll {
        width: 129px;
    }
    .laytable-cell-1-llll {
        width: 128px;
    }

    .laytable-cell-1-email {
        width: 209px;
    }

    .laytable-cell-1-tel {
        width: 156px;
    }

    .laytable-cell-1-locked {
        width: 156px;
    }

    .laytable-cell-1-createDate {
        width: 235px;
    }

    .laytable-cell-1-7 {
        width: 196px;
    }
</style>
<body>
<fieldset class="layui-elem-field">
    <legend>股东等级列表</legend>
    <div class="layui-field-box">
        <div class="layui-inline">
            <a href="/back/admin/level/addpage" class="layui-btn layui-btn-normal" data-type="addUser">添加等级</a>
            <button type='button' onclick='editRatio()'  class="layui-btn layui-btn-normal">编辑</button>
        </div>
    </div>
    <#--<div class="layui-form-item">-->
    <#--<label class="layui-form-label">币种</label>-->
    <#--<div class="layui-form-select">-->
    <#--<select id="coinTypeSelect" name="coinTypeId" lay-filter="aihao">-->
    <#--</select>-->
    <#--</div>-->
    <#--</div>-->
</fieldset>
<div class="layui-form layui-border-box layui-table-view" lay-filter="LAY-table-1" style="width:1190px; ">
    <div class="layui-table-box">
        <div class="layui-table-header">
            <table cellspacing="0" cellpadding="0" border="0" class="layui-table">
                <thead>
                <tr>
                    <!--编号、货币名称、交易场景、手续费、创建时间、操作-->
                    <th data-field="loginName">
                        <div class="layui-table-cell laytable-cell-1-ll"><span>编号</span></div>
                    </th>
                    <th data-field="nickName" >
                        <div class="layui-table-cell laytable-cell-1-lll"><span>币种名称</span></div>
                    </th>
                    <th data-field="nickName">
                        <div class="layui-table-cell laytable-cell-1-ll"><span>等级数字</span></div>
                    </th>
                    <th data-field="nickName">
                        <div class="layui-table-cell laytable-cell-1-tel"><span>等级名称</span></div>
                    </th>
                    <th data-field="email">
                        <div class="layui-table-cell laytable-cell-1-tel"><span>休眠币数量</span></div>
                    </th>
                    <th data-field="tel">
                        <div class="layui-table-cell laytable-cell-1-tel"><span>活币数量</span></div>
                    </th>
                    <th data-field="createDate" data-unresize="true">
                        <div class="layui-table-cell laytable-cell-1-createDate"><span>创建时间</span></div>
                    </th>
                    <th data-field="7">
                        <div class="layui-table-cell laytable-cell-1-7" align="center"><span>操作</span></div>
                    </th>
                </tr>
                </thead>
            </table>
        </div>
        <div class="layui-table-body layui-table-main">
            <table cellspacing="0" cellpadding="0" border="0" class="layui-table">
                <tbody id="levelListTBody">
                </tbody>

            </table>
        </div>
        <style>
            .laytable-cell-1-0 {
                width: 48px;
            }

            .laytable-cell-1-loginName {
                width: 178px;
            }

            .laytable-cell-1-nickName {
                width: 130px;
            }

            .laytable-cell-1-email {
                width: 209px;
            }

            .laytable-cell-1-tel {
                width: 156px;
            }

            .laytable-cell-1-locked {
                width: 156px;
            }

            .laytable-cell-1-createDate {
                width: 235px;
            }

            .laytable-cell-1-7 {
                width: 196px;
            }
        </style>
    </div>
    <script>


        $.ajax({
            url: "/back/admin/level/list",
            type: "GET",
            success: function (baseDto) {
                loadData(baseDto);
            }
        });


        function loadData(baseDto) {
            if (baseDto.code == ERROR)
                console.log(baseDto.msg);
            else {
                //数据
                var data = baseDto.data.list;
                var text = "";
                $.each(data, function (index, levelList) {
                    text += "<tr>\n" +
                        "<td data-field=\"loginName\">\n" +
                        "    <div id=\"+fee.id+\" class=\"layui-table-cell laytable-cell-1-ll\">" + levelList.id + "</div>\n" +
                        "</td>\n" +
                        "<td data-field=\"loginName\">\n" +
                        "    <div hidden id=\"+fee.id+\" class=\"layui-table-cell laytable-cell-1-ll\">" + levelList.coinTypeId + "</div>\n" +
                        "</td>\n" +
                        "<td data-field=\"loginName\">\n" +
                        "    <div  id=\"+fee.id+\" class=\"layui-table-cell laytable-cell-1-llll\">" + levelList.coinTypeName + "</div>\n" +
                        "</td>\n" +
                        "<td data-field=\"loginName\">\n" +
                        "    <div id=\"+fee.id+\" class=\"layui-table-cell laytable-cell-1-ll\">" + levelList.level + "</div>\n" +
                        "</td>\n" +
                        "<td>" + "<input type='text' id='name" + levelList.id + "' class='ayui-table-cell laytable-cell-1-tel' value='" + levelList.name + "' />" + "</td>\n" +
                        "<td>" + "<input type='text' id='aliveCoinCount" + levelList.id + "' class='ayui-table-cell laytable-cell-1-tel' value='" + levelList.aliveCoinCount + "' />" + "</td>\n" +
                        "<td>" + "<input type='text' id='sleepCoinCount" + levelList.id + "' class='ayui-table-cell laytable-cell-1-tel' value='" + levelList.sleepCoinCount + "' />" + "</td>\n" +
                        "<td data-field=\"loginName\">\n" +
                        "    <div id=\"+fee.id+\" class=\"layui-table-cell laytable-cell-1-createDate\">" + levelList.createTime + "</div>\n" +
                        "</td>\n" +
                        "<td class=\"layui-table-cell laytable-cell-1-7\" align=\"center\">\n" +
                        // "     <button type='button' onclick='getChange(" + levelList.id + ")'  class=\"layui-btn layui-btn-xs\">修改<button>\n" +
                        "     <button type='button' onclick='getChange(" + levelList.id + ")'  class=\"layui-btn layui-btn-xs\">修改</button>\n" +
                        "     <button type='button' onclick='getDel(" + levelList.id + ")'     class=\"layui-btn layui-btn-xs\">删除</button>\n" +
                        "</td>\n";
                    "</tr>";
                });
                var hangSaleListDom = $("#levelListTBody");
                hangSaleListDom.empty();//清空子元素
                hangSaleListDom.append($(text));

                var pages = baseDto.data.pages;
                var pageNum = baseDto.data.pageNum;
                console.log("pageNum=" + pageNum);
                var btnList = "";
                btnList += "<li class='first_page'><a onclick='loadPage(this)' link='/back/order/hangSale/list'>" + "首页" + "</a></li>";
                var temp = "<li class='prepage'><a onclick='loadPage(this)' link='/back/order/hangSale/list?pageNum=" + (pageNum - 1) + "'>上一页</a></li>";
                console.log("temp=" + temp);
                btnList += temp;
                for (var i = 0; i < pages; i++) {
                    btnList += ("<li class='prepage'><a onclick='loadPage(this)' link='/back/order/hangSale/list?pageNum=" + (i + 1) + "'>" + (i + 1) + "</a></li>\n")
                }
                btnList += ("<li class='nextpage'><a onclick='loadPage(this)' link='/back/order/hangSale/list?pageNum=" + (pageNum + 1) + "'>下一页</a></li>\n" +
                    "<li class='last_page' ><a onclick='loadPage(this)' link='/back/order/hangSale/list?pageNum=" + pages + "'>末页</a></li>");
                console.log(btnList);
                var pagination_ul = $("#pagination_ul");
                pagination_ul.empty();
                pagination_ul.append(btnList);
            }
        }

        function getChange(id) {
            var name = $("#name"+id+"").val();
            var aliveCoinCount = $("#aliveCoinCount"+id+"").val();
            var sleepCoinCount = $("#sleepCoinCount"+id+"").val();
            $.ajax({
                url: "/back/admin/level/update",
                type: "GET",
                data: {
                    id:id,
                    name: name,
                    aliveCoinCount: aliveCoinCount,
                    sleepCoinCount: sleepCoinCount
                },
                success: function (baseDto) {
                    loadData(baseDto);
                }
            });
        }

        function getDel(id) {
            $.ajax({
                url: "/back/admin/level/del",
                type: "GET",
                data: {
                    id: id
                },
                success: function (baseDto) {
                    loadData(baseDto);
                }
            });
        }


        // function loadPage(a) {
        //     var a_jquery = $(a);
        //     var url = a_jquery.attr("link");
        //     $.ajax(
        //         {
        //             url: url,
        //             type: "GET",
        //             success: function (baseDto) {
        //                 loadData(baseDto);
        //             }
        //         }
        //     );
        // }

    </script>
</body>
</html>